<?php
header("content-type:text/html;charset=utf-8");
date_default_timezone_set("PRC");
$active_code = $_GET['act'];
$active_decode = base64_decode($active_code);
$reg_time = strtotime(substr($active_decode, -14));
$timestamp = date("YmdHis");
$now = strtotime($timestamp);
$difference = ($now - $reg_time) / 86400;
$host = 'localhost';
$user = 'root';
$password = 'Xiangni365';
$database = 'login';

$con = mysqli_connect($host, $user, $password, $database);
if (!$con) {
    die(mysqli_connect_error());
}
$check = mysqli_fetch_array(mysqli_query($con, "SELECT * FROM login_check WHERE active_code='$active_code'"));
if ($difference < 1 || $check != null) {
    $active = mysqli_query($con, "UPDATE login_check SET active_status=1 WHERE active_code='$active_code'");
    echo ("<h1>用户$check[1]:你的账号已经激活成功！3秒后将跳转到登录页...</h1>");
    header("Refresh:3;url='http://47.107.66.0/form/login.html'");
}else{
    echo ("<h1>激活过期或激活地址无效！请联系管理员！</h1>");
}
